home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Almathera Ten Pack 3: CDPD 3
/
Almathera Ten on Ten - Disc 3: CDPD3.iso
/
fish
/
676-700
/
681
/
term
/
source.lha
/
termClip.c
< prev
next >
Wrap
C/C++ Source or Header
|
1992-05-09
|
2KB
|
115 lines
/*
** $Id: termClip.c,v 1.1 92/04/03 20:43:08 olsen Sta Locker: olsen $
** $Revision: 1.1 $
** $Date: 92/04/03 20:43:08 $
**
** Clipboard support routines
**
** Copyright © 1990-1992 by Olaf `Olsen' Barthel & MXM
** All Rights Reserved
*/
#include "termGlobal.h"
/* SaveClip(UBYTE *Buffer,LONG Size):
*
* Send a given text buffer to the clipboard.
*/
BYTE
SaveClip(UBYTE *Buffer,LONG Size)
{
BYTE Success = FALSE;
if(Size > 0)
{
struct IFFHandle *Handle;
if(Handle = AllocIFF())
{
if(Handle -> iff_Stream = (ULONG)OpenClipboard(PRIMARY_CLIP))
{
InitIFFasClip(Handle);
if(!OpenIFF(Handle,IFFF_WRITE))
{
if(!PushChunk(Handle,'FTXT','FORM',IFFSIZE_UNKNOWN))
{
if(!PushChunk(Handle,0,'CHRS',IFFSIZE_UNKNOWN))
{
if(WriteChunkBytes(Handle,Buffer,Size) == Size)
{
if(!PopChunk(Handle))
Success = TRUE;
}
}
}
if(Success)
{
if(PopChunk(Handle))
Success = FALSE;
}
CloseIFF(Handle);
}
CloseClipboard((struct ClipboardHandle *)Handle -> iff_Stream);
}
FreeIFF(Handle);
}
}
return(Success);
}
/* LoadClip(UBYTE *Buffer,LONG Size):
*
* Put the contents of the clipboard into a given
* buffer.
*/
LONG
LoadClip(UBYTE *Buffer,LONG Size)
{
struct IFFHandle *Handle;
LONG Bytes = 0;
if(Handle = AllocIFF())
{
if(Handle -> iff_Stream = (ULONG)OpenClipboard(PRIMARY_CLIP))
{
InitIFFasClip(Handle);
if(!OpenIFF(Handle,IFFF_READ))
{
if(!StopChunk(Handle,'FTXT','CHRS'))
{
if(!ParseIFF(Handle,IFFPARSE_SCAN))
{
struct ContextNode *ContextNode;
if(ContextNode = CurrentChunk(Handle))
{
if(Size > ContextNode -> cn_Size)
Size = ContextNode -> cn_Size;
if(ReadChunkRecords(Handle,Buffer,Size,1))
Bytes = Size;
}
}
}
CloseIFF(Handle);
}
CloseClipboard((struct ClipboardHandle *)Handle -> iff_Stream);
}
FreeIFF(Handle);
}
return(Bytes);
}